package com.rysm.wjsm.demo3;
/*
同时开启两个线程，共同输出1-100之间的所有数字，并且将输出奇数的线程名称打印出来
 */
public class MyRunnable implements Runnable{
    private int ticket = 100;

    @Override
    public void run() {

            while (true){
                synchronized (MyRunnable.class){
                if (ticket <= 0){
                    break;
                }else {
                    if (ticket % 2 == 0){

                        System.out.println(Thread.currentThread().getName() + --ticket);
                    }else {
                        System.out.println(--ticket);
                    }

                }
            }
        }
    }
}
